package com.youku.controls
{
   import com.youku.plugins.jump.JumpFacade;
   import com.youku.GlobalService;
   import com.youku.GlobalServiceKeys;
   import com.youku.events.PluginEvent;
   import com.youku.interfaces.IPlayListData;
   import com.youku.events.PlayerControlEvent;
   import com.youku.PlayerConfig;
   
   public class JumpController extends BasePluginController
   {
      
      public function JumpController() {
         super();
         this.init();
      }
      
      private var _jumpFacade:JumpFacade;
      
      override protected function init() : void {
         this._jumpFacade = JumpFacade.getInstance();
         this._jumpFacade.init(viewManager.pluginLayer,playerProxy);
         GlobalService.addService(GlobalServiceKeys.JUMP_FACADE,this._jumpFacade);
         playerProxy.addEventListener(PluginEvent.JUMP_TAIL,this.onJumpEvent);
         playerProxy.addEventListener(PluginEvent.JUMP_HEAD,this.onJumpEvent);
      }
      
      private function onJumpEvent(param1:PluginEvent) : void {
         var _loc2_:IPlayListData = null;
         var _loc3_:* = NaN;
         var _loc4_:* = NaN;
         switch(param1.type)
         {
            case PluginEvent.JUMP_TAIL:
               playerProxy.dispatchEvent(new PlayerControlEvent(PlayerControlEvent.CORE_JUMP_TAIL));
               break;
            case PluginEvent.JUMP_HEAD:
               _loc2_ = PlayerConfig.playListData;
               _loc3_ = 0;
               if(!(_loc2_.dvdinfo == null) && !(_loc2_.dvdinfo.headPostion == -1))
               {
                  _loc3_ = _loc2_.dvdinfo.headPostion;
               }
               _loc4_ = _loc3_ / 1000;
               playerProxy.dispatchEvent(new PlayerControlEvent(PlayerControlEvent.CORE_SEEK,{"time":_loc4_}));
               playerProxy.dispatchEvent(new PlayerControlEvent(PlayerControlEvent.INFO_JUMP_HEAD));
               break;
         }
      }
   }
}
